<?php

class ajaxActions extends sfActions {

    public function preExecute() {
        date_default_timezone_set(AppTools::TIMEZONE);
    }

    public function executeProduct(sfWebRequest $request) {
        $withPrice = $request->getParameter('with_price', 0);
        $categoryId = $request->getParameter('category_id', 0);
        $products = ProductTable::getForSelect($categoryId, $withPrice);
        $json = json_encode($products);
        return $this->renderText($json);
    }

    public function executeUser(sfWebRequest $request) {
        $storeId = $request->getParameter('store_id', 0);
        $type = $request->getParameter('type', 0);
        $users = UserTable::getForSelect($storeId, $type);
        $json = json_encode($users);
        return $this->renderText($json);
    }

    public function executeManufacturer(sfWebRequest $request) {
        $manufacturers = ManufacturerTable::getForSelect();
        $json = json_encode($manufacturers);
        return $this->renderText($json);
    }

    public function executeCustomer(sfWebRequest $request) {
        $customers = CustomerTable::getForSelect();
        $json = json_encode($customers);
        return $this->renderText($json);
    }

    public function executeStore(sfWebRequest $request) {
        $stores = StoreTable::getForSelect();
        $json = json_encode($stores);
        return $this->renderText($json);
    }

}
